<template>
	<view :class="{'flex-flow':flexFlow}" class="chat-item">
		<view class="chat-head" @click="callFatherMethod()">
			<image :src="customData.avatar" mode="aspectFill"></image>
		</view>
		<view :class="['chat-wxbox',isFriendCheck(customData.message.messageID,'friends') ? '' : 'chat-mask']">
			<view class="chat-tit">
				<view class="tit-head">
					<image :src="ossPath+`/chat/friend.png`" mode="aspectFill"></image>
				</view>
				<view class="tit-text">
					对方想要添加您为好友，您是否同意？
				</view>
			</view>
			<view class="chat-btn" v-if="isFriendCheck(customData.message.messageID,'friends')">
				<view class="btn-item" @click="callFatherMethod2(-1)">
					拒绝
				</view>
				|
				<view class="btn-item" style="color: #111;" @click="callFatherMethod2(1)">
					同意
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		name: "chatBeApplyFriend",
		props:{
			flexFlow:{
				type:Boolean,
				default:true,
			},
			customData:{
				type:Object,
				default:{
					avatar:'',
					userId:0,
					message:{
						messageID:0,
						EventID:0
					}
				},
			}
		},
		data() {
			return {
				ossPath:'',
			};
		},
		created() {
			
		},
		mounted() {
			this.ossPath = this.$ossPath;
		},
		methods: {
			isFriendCheck(msgId,type){
					if(type=='friends') return !((uni.getStorageSync('friends_') || []).some(item=>item.msgId==msgId))
					if(type=='wx') return !((uni.getStorageSync('wx_') || []).some(item=>item.msgId==msgId))
			},
			callFatherMethod(status){
				this.$emit('callFatherMethod',this.customData.userId)
			},
			callFatherMethod2(){
				this.$emit('callFatherMethod2',status,this.customData.message.EventID,this.customData.message.messageID)
			}
		},
	};
</script>

<style lang="scss" scoped>

	
</style>